import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { alarmStrategyVO, alarmStrategyForm, alarmStrategyQuery } from '@/api/workbench/alarm/alarm-strategy/types';

/**
 * 查询告警策略列表
 * @param query
 * @returns {*}
 */

export const listalarmStrategy = (query?: alarmStrategyQuery): AxiosPromise<alarmStrategyVO[]> => {
  return request({
    url: '/alarm/alarm-strategy/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询告警策略详细
 * @param alarmStrategyId
 */
export const getalarmStrategy = (alarmStrategyId: string | number): AxiosPromise<alarmStrategyVO> => {
  return request({
    url: '/alarm/alarm-strategy/' + alarmStrategyId,
    method: 'get'
  });
};

/**
 * 新增告警策略
 * @param data
 */
export const addalarmStrategy = (data: alarmStrategyForm) => {
  return request({
    url: '/alarm/alarm-strategy',
    method: 'post',
    data: data
  });
};

/**
 * 修改告警策略
 * @param data
 */
export const updatealarmStrategy = (data: alarmStrategyForm) => {
  return request({
    url: '/alarm/alarm-strategy',
    method: 'put',
    data: data
  });
};

/**
 * 删除告警策略
 * @param alarmStrategyId
 */
export const delalarmStrategy = (alarmStrategyId: string | number | Array<string | number>) => {
  return request({
    url: '/alarm/alarm-strategy/' + alarmStrategyId,
    method: 'delete'
  });
};

/**
 * 获取设备类型树列表
 *
 */
export const getEquipmentTypeTree = () => {
  return request({
    url: '/equipment/equipment-type/treeList' ,
    method: 'get'
  });
};

/**
 * 根据设备类型获取产品列表
 *
 */
export const getProductListByEquipmentType = (equipmentTypeId: string | number) => {
  return request({
    url: '/equipment/equipment-product/getProductListByEquipmentType/'+equipmentTypeId ,
    method: 'get'
  });
};

/**
 * 根据产品获取事件列表
 *
 */
export const getEventByProductionId = (productionId: string | number) => {
  return request({
    url: '/equipment/equipment-product/getEventByProductionId/'+productionId ,
    method: 'get'
  });
};

/**
 * 根据事件获取参数列表
 *
 */
export const getParamsByEventId = (eventId: string | number) => {
  return request({
    url: '/equipment/equipment-product/getParamsByEventId/'+eventId ,
    method: 'get'
  });
};


/**
 * 根据角色ID查询用户列表
 *
 */
export const getUserByRoleId = (roleId: string | number) => {
  return request({
    url: '/system/user/getUserByRoleId/'+roleId ,
    method: 'get'
  });
};
